package org.HisCanvas.ChrisRiffle.JFlightLog.swingUi.table;

import java.text.NumberFormat;

import javax.swing.table.DefaultTableCellRenderer;




/**
 * FlightTableHoursDecimalCellRenderer
 * 
 * @author rif 
 */
public class FlightTableHoursDecimalCellRenderer extends DefaultTableCellRenderer {
	
	
	private static NumberFormat hoursFloatFormat;
	
	private static FlightTableHoursDecimalCellRenderer INSTANCE;
	
	

	/**
	 * Default Constructor
	 */
	private FlightTableHoursDecimalCellRenderer() {
	
		hoursFloatFormat = NumberFormat.getInstance();
		
		// just one decimal place(common USA flight-hour format) for tenths of minutes
		hoursFloatFormat.setMaximumFractionDigits(1);	
	}
	
	
	
	public static FlightTableHoursDecimalCellRenderer instance() {
		
		if(INSTANCE == null){
			
			INSTANCE = new FlightTableHoursDecimalCellRenderer();
		}
		return INSTANCE;
	}
	
	
	
	@Override
	protected void setValue(Object value) {
			
		
		
		
		setText(value == null ? "" : hoursFloatFormat.format(value));
				
	}

}


